import { MockMethod } from "vite-plugin-mock"

export default [
  {
    url: "/dev-api/goods/list/search",
    timeout: 2000,
    method: "get",
    response: () => {
      return {
        "code": 20000,
        "message": "查询成功",
        "data": {
          "total": "@integer(100, 200)", // 总记录数
          "records|20": [{ //生成20条数据
            "id|+1": 1, //初始值1开始，每条+1
            "code": "@integer(1)",
            "name": "@name",
            "imageUrl": "@image",
            "quickCode": "@word(4)",
            "specsName": '@cword(3, 5)', // 规格名称
            "unitName": "@cword(1)",
            "categoryId|+1": 10,
            "categoryName": "@first",
            "cost": 0.0000, // 成本价
            "stockNum|100-2000": 0, // 随机生成 100到2000
            "price|300-6000.2": 0, // 随机生成300到6000, 有2位小数
            "discountPrice|100-3000.2": 0, // 优惠价
            "score|0-300": 0, // 可获得积分
            "address": "@county(true)", // 生产地址，省市县
            "brand": "@ctitle(3)", // 品牌
            "status|1": [0, 1], // 状态：0下架，1上架
            "sort|1-100": 0,
            "remark": "@ctitle",
            "goodsDetail": "@csentence(10, 30)", // 一段中文文本(10到30个字)
            "createTime": "@datetime",
            "updateTime": "@datetime"
          }]
        }
      }
    }
  },
  {
    url: "/dev-api/goods/list/search",
    timeout: 2000,
    method: "post",
    response: () => {
      return {
        "code": 20000,
        "message": "查询成功",
        "data": {
          "total": "@integer(100, 200)", // 总记录数
          "records|20": [{ //生成20条数据
            "id|+1": 1, //初始值1开始，每条+1
            "roleName|1": ['超级管理员', '售前客服', '售后客服'],
            "roleCode": "ROLE_" + "@word(5)", // ROLE_5个英文字符
            'status|10-2': true, // Boolean, 生成 true 概率 10/(10+2), false 概率 2/(10+2)
            "remark": "@ctitle",
            "createTime": "@date", // 随机创建时间
            "updateTime": "@date", // 随机更新时间
          }]
        }
      }
    }
  },
  {
    url: "/dev-api/goods/list/:id",
    timeout: 2000,
    method: "delete",
    response: () => {
      return {
        "code": 20000,
        "message": "删除成功",
        "data": true
      }
    }
  },
  {
    url: "/dev-api/goods/list/status",
    timeout: 2000,
    method: "put",
    response: () => {
      return {
        "code": 20000,
        "message": "更新成功",
        "data": { "code": 20000 }
      }
    }
  },
  {
    url: "/dev-api/system/media/upload/img",
    timeout: 2000,
    method: "post",
    response: () => {
      return {
        "code": 20000,
        "message": "上传成功",
        "data": {
          "url": 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg',
          "alt": "这是图片",
          "href": "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg"
        }
      }
    }
  },
] as MockMethod[]